package com.grape.springbootgradle20220520.base.thread;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

public class MainThread {
    public static void main(String[] args) throws InterruptedException {
//        System.out.println("main start");
//        Thread thread = new Thread(() -> {
//            System.out.println("hello world");
//        });
//        thread.start();
//        thread.join();
//        System.out.println("main end");
        ExecutorService service = Executors.newFixedThreadPool(3);
        for (int i = 0; i < 6; i++) {
            service.submit(new UserThread());
        }

        service.shutdown();
    }
}

class UserThread implements Runnable{
//    AtomicInteger num;
    @Override
    public void run() {
//        int i = num.incrementAndGet();
        System.out.println("hello world");
    }
}
